package operateur;

/**
 * Interface definition : GestionPaiement
 * 
 * @author OpenORB Compiler
 */
public class _GestionPaiementStub extends org.omg.CORBA.portable.ObjectImpl
        implements GestionPaiement
{
    static final String[] _ids_list =
    {
        "IDL:operateur/GestionPaiement:1.0"
    };

    public String[] _ids()
    {
     return _ids_list;
    }

    private final static Class _opsClass = operateur.GestionPaiementOperations.class;

    /**
     * Operation debiterCpt
     */
    public float debiterCpt(String idUtilisateur, float montant)
        throws operateur.MontantNegatif
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("debiterCpt",true);
                    operateur.identHelper.write(_output,idUtilisateur);
                    operateur.soldeHelper.write(_output,montant);
                    _input = this._invoke(_output);
                    float _arg_ret = operateur.soldeHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    if (_exception_id.equals(operateur.MontantNegatifHelper.id()))
                    {
                        throw operateur.MontantNegatifHelper.read(_exception.getInputStream());
                    }

                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("debiterCpt",_opsClass);
                if (_so == null)
                   continue;
                operateur.GestionPaiementOperations _self = (operateur.GestionPaiementOperations) _so.servant;
                try
                {
                    return _self.debiterCpt( idUtilisateur,  montant);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation crediterCpt
     */
    public float crediterCpt(String idUtilisateur, float montant)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("crediterCpt",true);
                    operateur.identHelper.write(_output,idUtilisateur);
                    operateur.soldeHelper.write(_output,montant);
                    _input = this._invoke(_output);
                    float _arg_ret = operateur.soldeHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("crediterCpt",_opsClass);
                if (_so == null)
                   continue;
                operateur.GestionPaiementOperations _self = (operateur.GestionPaiementOperations) _so.servant;
                try
                {
                    return _self.crediterCpt( idUtilisateur,  montant);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation creerCpt
     */
    public float creerCpt(String idUtilisateur, String cptUtilisateur, float montant)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("creerCpt",true);
                    operateur.identHelper.write(_output,idUtilisateur);
                    operateur.infoPaiementHelper.write(_output,cptUtilisateur);
                    operateur.soldeHelper.write(_output,montant);
                    _input = this._invoke(_output);
                    float _arg_ret = operateur.soldeHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("creerCpt",_opsClass);
                if (_so == null)
                   continue;
                operateur.GestionPaiementOperations _self = (operateur.GestionPaiementOperations) _so.servant;
                try
                {
                    return _self.creerCpt( idUtilisateur,  cptUtilisateur,  montant);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

    /**
     * Operation getSolde
     */
    public float getSolde(String idUtilisateur)
    {
        while(true)
        {
            if (!this._is_local())
            {
                org.omg.CORBA.portable.InputStream _input = null;
                try
                {
                    org.omg.CORBA.portable.OutputStream _output = this._request("getSolde",true);
                    operateur.identHelper.write(_output,idUtilisateur);
                    _input = this._invoke(_output);
                    float _arg_ret = operateur.soldeHelper.read(_input);
                    return _arg_ret;
                }
                catch(org.omg.CORBA.portable.RemarshalException _exception)
                {
                    continue;
                }
                catch(org.omg.CORBA.portable.ApplicationException _exception)
                {
                    String _exception_id = _exception.getId();
                    throw new org.omg.CORBA.UNKNOWN("Unexpected User Exception: "+ _exception_id);
                }
                finally
                {
                    this._releaseReply(_input);
                }
            }
            else
            {
                org.omg.CORBA.portable.ServantObject _so = _servant_preinvoke("getSolde",_opsClass);
                if (_so == null)
                   continue;
                operateur.GestionPaiementOperations _self = (operateur.GestionPaiementOperations) _so.servant;
                try
                {
                    return _self.getSolde( idUtilisateur);
                }
                finally
                {
                    _servant_postinvoke(_so);
                }
            }
        }
    }

}
